<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test2</title>
</head>
<body>
<form name="form1" method="post" action="">
    请输入真实姓名:<input name="realName" type="text" id="realName" size="40">
    <br><br>
    <input name="Button" type="button" class="btn_grey" value="检测" onclick="check()">
</form>

<script>
    function check() {
        var str=form1.realName.value();
        if(str==""){
            alert("请输入你的真实姓名。");
        }else {
            var objExp=/[\u4E00-\u9FA5]{2,}/;
            if(objExp.test(str)==true){
                alert("您输入的真实姓名正确！");
            }else {
                alert("您输入的真实姓名错误！");
            }
        }
    }
</script>
</body>
</html>